{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "e5d4837e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 0.0 0.08286135043349964 0.08286135043349964\n",
      "1 0.08286135043349964 0.25118864315095796 0.16832729271745833\n",
      "2 0.25118864315095796 0.4805582246305208 0.22936958147956282\n",
      "3 0.4805582246305208 0.7614615754863513 0.2809033508558305\n",
      "4 0.7614615754863513 1.088188204120155 0.32672662863380364\n",
      "5 1.088188204120155 1.4567801244906113 0.3685919203704564\n",
      "6 1.4567801244906113 1.8642702577112429 0.40749013322063155\n",
      "7 1.8642702577112429 2.3083198494515416 0.4440495917402987\n",
      "8 2.3083198494515416 2.7870195942000233 0.47869974474848176\n",
      "9 2.7870195942000233 3.2987697769322355 0.5117501827322122\n",
      "10 3.2987697769322355 3.842202968380542 0.5434331914483064\n",
      "11 3.842202968380542 4.416131536906999 0.573928568526457\n",
      "12 4.416131536906999 5.019510541446327 0.6033790045393284\n",
      "13 5.019510541446327 5.651410628131081 0.6319000866847535\n",
      "14 5.651410628131081 6.310997693134873 0.6595870650037918\n",
      "15 6.310997693134873 6.99751727323698 0.6865195801021073\n",
      "16 6.99751727323698 7.710282331663665 0.7127650584266849\n",
      "17 7.710282331663665 8.448663540236124 0.7383812085724593\n",
      "18 8.448663540236124 9.212081434582966 0.7634178943468424\n",
      "19 9.212081434582966 10.0 0.7879185654170335\n",
      "0 0.0\n",
      "1 4.742747411323311\n",
      "2 7.314316399918298\n",
      "3 9.423902405005808\n",
      "4 11.280217932412837\n",
      "5 12.9683955465101\n",
      "6 14.533644306587888\n",
      "7 16.003547774916488\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "binPow = 1.6\n",
    "maxR = 8\n",
    "kernelSize = 20\n",
    "kernelDist = 10\n",
    "\n",
    "def v(x):\n",
    "    return x**binPow/kernelSize**binPow * kernelDist\n",
    "\n",
    "def bin(i):\n",
    "    return ( i * (kernelSize**binPow) / kernelDist ) ** (1/binPow)\n",
    "\n",
    "for i in range(kernelSize):\n",
    "    print(i, v(i), v(i+1), v(i+1)-v(i))\n",
    "\n",
    "for i in range(maxR):\n",
    "    print(i, bin(i))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "d05552c2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 0.4762870634112166\n",
      "1 0.4403985389889412\n",
      "2 0.36552928931500245\n",
      "3 0.25\n",
      "4 0.13447071068499755\n",
      "5 0.05960146101105884\n",
      "6 0.023712936588783318\n",
      "7 0.008993104981045774\n",
      "8 0.003346425462142366\n",
      "9 0.0012363115783173284\n",
      "10 0.0004555255972003014\n",
      "11 0.00016767506523318598\n",
      "12 6.169728799315655e-05\n",
      "13 2.2698934351195188e-05\n",
      "14 8.350710923976656e-06\n",
      "15 3.072087301103643e-06\n",
      "16 1.1301621489767655e-06\n",
      "17 4.157640138835461e-07\n",
      "18 1.529511134967798e-07\n",
      "19 5.626758103893792e-08\n"
     ]
    }
   ],
   "source": [
    "def f(x,p0,p1,p2,p3):\n",
    "    return p0-(p1/(1+np.exp(-p2*(x-p3))))\n",
    "\n",
    "for x in range(0,20,1):\n",
    "    print(x, f(x,0.5,0.5,1,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "4002c703",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{1}{\\left(1 + e^{- p_{2} \\left(- p_{3} + x\\right)}\\right) \\left(- p_{0} + \\frac{p_{1}}{1 + e^{- p_{2} \\left(- p_{3} + x\\right)}} + v\\right)}$"
      ],
      "text/plain": [
       "1/((1 + exp(-p2*(-p3 + x)))*(-p0 + p1/(1 + exp(-p2*(-p3 + x))) + v))"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sympy import *\n",
    "\n",
    "p0,p1,p2,p3,x,v = symbols('p0 p1 p2 p3 x v')\n",
    "\n",
    "diff(ln(v - (p0-(p1/(1+exp(-p2*(x-p3)))))),p1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5b99c0ca",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
